package com.desire.remote;

import com.desire.bean.User;
import com.desire.factory.UserRemoteClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Description:
 * @Author: littleDesire
 * @Date: 2022-06-08 21:46
 * @Version: 1.0
 */
//@FeignClient(value = "ERP-SYSTEM", fallback = UserFallback.class)
@FeignClient(value = "ERP-SYSTEM", fallbackFactory = UserRemoteClientFallbackFactory.class) // 工厂方式回退降级
public interface UserRemoteClient {


    /**
     * 普通方式调用
     *
     * @return map
     */
    @GetMapping("/user/query")
    Map<String, Object> queryUser();


    /**
     * 路径传值方式调用
     *
     * @param id id
     * @return map
     */
    @GetMapping("/user/query/{id}")
    Map<String, Object> queryPath(@PathVariable("id") String id);

    /**
     * 普通带参方式调用
     */
    @GetMapping("/user/queryParams")
    Map<String, Object> queryParams(@RequestParam("username") String username, @RequestParam("password") String password);

    /**
     * map传值方式调用 get
     */
    @GetMapping("/user/queryGetMap")
    void queryGetMap(@RequestParam Map<String, Object> map);

    /**
     * map传值方式调用 post
     */
    @PostMapping("/user/queryPostMap")
    void queryPostMap(@RequestBody Map<String, Object> map);

    /**
     * 对象传值方式调用
     */
    @PostMapping("/user/queryPostUser")
    void queryPostUser(@RequestBody User user);

    /**
     * SpringQueryMap 官方的传值方式 map
     */
    @GetMapping("/user/queryStringQueryMap")
    void queryStringQueryMap(@SpringQueryMap Map<String, Object> map);

    /**
     * SpringQueryMap 官方的传值方式 User
     */
    @GetMapping("/user/queryStringQueryMapUser")
    void queryStringQueryMapUser(@SpringQueryMap User user);

}
